

$(function(){

    $('#loginBtn').on('click', function(){
        
        var username = $('#username').val();
        var password = $('#password').val();
        if(username.trim() == '') {
            mui.toast("请输入用户名!");
            return;
        }
        if(password.trim() == '') {
            mui.toast("请输入密码!");
            return;
        }
    
        $.ajax({
            url: '/user/login',
            type: 'post',
            data: {
                username: username,
                password: password,
            },
            dataType: 'json',
            success: function (info) {
                console.log(info);
                if(info.error) {
                    mui.toast(info.message);
                    return;
                }

                if(info.success) {
                    // 登入成功  进行跳转
                    location.href = 'user.html';
                }
            }
        })

    })


})